import { useMemo, useState } from "react";

function App() {
  const [count, setCount] = useState(() => {
    return 0
  })

  function handleCount() {
    setCount(() => {
      return count + 1
    })
  }

  const result = useMemo(() => {
    return count * 2
  }, [count])

  return (
    <div>
      <h1>{count}</h1>
      <h1>{result}</h1>
      <button onClick={handleCount}>+</button>
    </div>
  );
}

export default App;
